/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PrintingPnl.java
 *
 * Created on Jul 19, 2011, 10:08:13 PM
 */
package com.viweb.storemanager.ui.config;

import com.viweb.storemanager.entity.InfoConfig;

/**
 *
 * @author qhvic
 */
public class ConfigInfoPnl extends javax.swing.JPanel {

    private String validDescription;
    private InfoConfig infoConfig;

    /** Creates new form PrintingPnl */
    public ConfigInfoPnl() {
        initComponents();
    }

    public boolean updateConfig() {
        if (this.txtName.getText().trim().equals("")) {
            this.setValidDescription("Chưa thiết lập thông tin tên tài khoản!");
            return false;
        }

        if (this.txtAddress.getText().trim().equals("")) {
            this.setValidDescription("Chưa thiết lập thông tin mật khẩu!");
            return false;
        }

        if (this.txtPhone.getText().trim().equals("")) {
            this.setValidDescription("Chưa thiết lập thông tin server!");
            return false;
        }

        if (this.txtWebsite.getText().trim().equals("")) {
            this.setValidDescription("Chưa thiết lập thông tin cổng!");
            return false;
        }

        infoConfig.setName(this.txtName.getText().trim());
        infoConfig.setAddress(this.txtAddress.getText().trim());
        infoConfig.setPhone(this.txtPhone.getText().trim());
        infoConfig.setWeb(this.txtWebsite.getText().trim());

        return true;
    }

    public String getValidDescription() {
        return validDescription;
    }

    public void setValidDescription(String validDescription) {
        this.validDescription = validDescription;
    }

    @Override
    public void requestFocus() {
        this.txtName.requestFocus();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        pnlName = new javax.swing.JPanel();
        lblName = new javax.swing.JLabel();
        sep1 = new javax.swing.JSeparator();
        pnlContactInfo = new javax.swing.JPanel();
        lblContactInfo = new javax.swing.JLabel();
        sep2 = new javax.swing.JSeparator();
        lblTitle = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        lblAddress = new javax.swing.JLabel();
        lblPhone = new javax.swing.JLabel();
        lblWebsite = new javax.swing.JLabel();
        txtWebsite = new javax.swing.JTextField();
        scpAddress = new javax.swing.JScrollPane();
        txtAddress = new javax.swing.JTextArea();
        txtPhone = new javax.swing.JFormattedTextField();

        setLayout(new java.awt.GridBagLayout());

        pnlName.setLayout(new java.awt.GridBagLayout());

        lblName.setText("Tên cửa hàng");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        pnlName.add(lblName, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        pnlName.add(sep1, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(pnlName, gridBagConstraints);

        pnlContactInfo.setLayout(new java.awt.GridBagLayout());

        lblContactInfo.setText("Thông tin liên hệ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        pnlContactInfo.add(lblContactInfo, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        pnlContactInfo.add(sep2, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 5);
        add(pnlContactInfo, gridBagConstraints);

        lblTitle.setBackground(new java.awt.Color(153, 0, 102));
        lblTitle.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblTitle.setForeground(new java.awt.Color(0, 0, 204));
        lblTitle.setText(" Thiết lập thông tin");
        lblTitle.setMaximumSize(new java.awt.Dimension(129, 30));
        lblTitle.setMinimumSize(new java.awt.Dimension(129, 30));
        lblTitle.setPreferredSize(new java.awt.Dimension(129, 30));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
        add(lblTitle, gridBagConstraints);

        txtName.setMinimumSize(new java.awt.Dimension(6, 25));
        txtName.setPreferredSize(new java.awt.Dimension(6, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 5);
        add(txtName, gridBagConstraints);

        lblAddress.setText("Địa chỉ:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 5, 0);
        add(lblAddress, gridBagConstraints);

        lblPhone.setText("Phone:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 5, 0);
        add(lblPhone, gridBagConstraints);

        lblWebsite.setText("Website:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 5, 0);
        add(lblWebsite, gridBagConstraints);

        txtWebsite.setMinimumSize(new java.awt.Dimension(200, 25));
        txtWebsite.setPreferredSize(new java.awt.Dimension(200, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(txtWebsite, gridBagConstraints);

        txtAddress.setColumns(20);
        txtAddress.setRows(5);
        scpAddress.setViewportView(txtAddress);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(scpAddress, gridBagConstraints);

        txtPhone.setMinimumSize(new java.awt.Dimension(200, 25));
        txtPhone.setPreferredSize(new java.awt.Dimension(200, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        add(txtPhone, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblContactInfo;
    private javax.swing.JLabel lblName;
    private javax.swing.JLabel lblPhone;
    private javax.swing.JLabel lblTitle;
    private javax.swing.JLabel lblWebsite;
    private javax.swing.JPanel pnlContactInfo;
    private javax.swing.JPanel pnlName;
    private javax.swing.JScrollPane scpAddress;
    private javax.swing.JSeparator sep1;
    private javax.swing.JSeparator sep2;
    private javax.swing.JTextArea txtAddress;
    private javax.swing.JTextField txtName;
    private javax.swing.JFormattedTextField txtPhone;
    private javax.swing.JTextField txtWebsite;
    // End of variables declaration//GEN-END:variables
}
